//
//  UIImageViewEx.swift
//  Mall-swift
//
//  Created by dfpo on 2020/11/8.
//  Copyright © 2020 Bob. All rights reserved.
//

import Foundation
import UIKit
import Kingfisher
extension UIImageView {
    
    /// 加载图片
    /// - Parameters:
    ///   - imgUrlStr: url字符串
    ///   - imgWH: 图片宽高
    public func configUrlStr(_ imgUrlStr: String?, imgWH: CGFloat)  {
        if let imgUrlStr = imgUrlStr {
            configUrl(URL(string: imgUrlStr), imgWH: imgWH)
        }
    }
    
    /// 加载图片
    /// - Parameters:
    ///   - imgUrl: url
    ///   - imgWH: 图片宽高
    public func configUrl(_ imgUrl: URL?, imgWH: CGFloat)  {
        let processor = DownsamplingImageProcessor(size: CGSize(width: imgWH, height: imgWH))
        kf.setImage(with: imgUrl,
                                options:[.processor(processor), .transition(.fade(0.5))]);
    }
    
}
